<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>用户列表</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
    <div class="container">
        <div class="row">
            <nav class="navbar navbar-inverse" style="margin-bottom:3px;">
                <div class="container-fluid">
                    <!-- Brand and toggle get grouped for better mobile display -->
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="#">欢迎~ {$Request.session.username.username}</a>
                    </div>
                    <!-- Collect the nav links, forms, and other content for toggling -->
                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                        <ul class="nav navbar-nav navbar-right">
                            <form class="navbar-form navbar-left" action="index" method="get">
                                <div class="form-group">
                                    <input type="text" class="form-control" name="keyword" placeholder="">
                                </div>
                                <button type="submit" class="btn btn-default">搜索</button>
                            </form>


                            <a href="/test/login/logout" class="btn btn-danger glyphicon glyphicon-off btn-xs" style="margin-bottom: 5px;margin-top: 12px;padding: 2px 20px;">退出</a>
                        </ul>
                    </div><!-- /.navbar-collapse -->
                </div><!-- /.container-fluid -->
            </nav>
            <img src="\public\uploads\20181022\af500af9f40f9c98b8e7b2ddf6765210.jpg" alt="">55
            <table class="table table-bordered">
                <a href="insert" class="btn btn-success glyphicon glyphicon-plus" style="margin-bottom: 5px;">新增数据</a>
                <thead>
                <tr>
                    <th>编号</th>
                    <th>幼儿园</th>
                    <th>电话</th>
                    <th>地址</th>
                    <th>时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="tushu" id="vo"}
                <tr>
                    <td>{$vo.id}</td>
                    <td>{$vo.title}</td>
                    <td>{$vo.tel}</td>
                    <td>{$vo.addr}</td>
                    <td>{$vo.create_time}</td>
                    <td>
                        <a href="update?id={$vo.id}" class="btn btn-primary glyphicon glyphicon-pencil btn-sm">编辑</a>
                        <button class="btn btn-danger glyphicon glyphicon-trash btn-sm" data-toggle="modal" data-target="#myModal" data-id="{$vo.id}">删除</button>
                    </td>
                </tr>
                <!-- 模态框（Modal） -->
                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                    &times;
                                </button>
                                <h4 class="modal-title" id="myModalLabel">
                                    确认删除该数据？
                                </h4>
                            </div>
                            <div class="modal-footer" style="text-align: center">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                                </button>&nbsp;&nbsp;&nbsp;
                                <button type="button" class="btn btn-primary J-my-madal-id">
                                    删除
                                </button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal -->
                </div>
                {/volist}
                </tbody>
            </table>
            {$page}
        </div>
    </div>
    <script>
        $('#myModal').on('show.bs.modal', function(e){
            var button = $(e.relatedTarget);
            var id = button.data('id');
            $('.J-my-madal-id').attr('data-id', id);
        });
        $('.J-my-madal-id').click(function(){
            var id = $(this).attr('data-id');
            $.ajax({
                url: 'delete',
                type: 'GET',
                data:{'id': id},
                dataType:'JSON',
                success:function(data){
                    if(data.status == 1){
                        window.location.reload();
                    }
                }
            })
        });
    </script>
</body>
</html>